home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / buffdemo.zip / BUFFDEMO.BAS next >
BASIC Source File  |  1986-05-12  |  10KB  |  200 lines

  1. 1 GOTO 240             'Line 1 MUST be present for this program to work.
  2. 5 ' LISTING 3
  3. 10 '
  4. 20 '>>>>>>>>>>>>>  This line will be deleted in the demo
  5. 30 '>>>>>>>>>>>>>  This line will be deleted in the demo
  6. 40 '>>>>>>>>>>>>>  This line will be deleted in the demo
  7. 50 '>>>>>>>>>>>>>  This line will be deleted in the demo
  8. 60 '>>>>>>>>>>>>>  This line will be deleted in the demo
  9. 70 '>>>>>>>>>>>>>  This line will be deleted in the demo
  10. 80 '>>>>>>>>>>>>>  This line will be deleted in the demo
  11. 90 '
  12. 100 '===========  Demo of keyboard buffer loader  =====================
  13. 110 '
  14. 120 'BUFFDEMO.BAS  Version 2.20, Copyright, 1985
  15. 130 '
  16. 140 'By:  Jim Pottkotter
  17. 150 '     3015 Kirby M'Liss Cove
  18. 160 '     Memphis, TN 38115
  19. 170 '
  20. 200 '==================  Purpose of BUFFDEMO.BAS  ====================
  21. 210 '
  22. 220 'Demostrates possible uses of BUFFLOAD.SUB
  23. 230 '
  24. 240 IF X = Y GOTO 300                   'Skip special branches
  25. 250 ON X GOTO 1060,1120,1180            'Branch for renumbering test
  26. 260 ON Y GOTO 1300,1360,1420            'Branch for delete test
  27. 270   BEEP
  28. 280   PRINT "Unexpected value for X."                  'Message
  29. 290   STOP
  30. 300 WHILE NOT HOUSEKEEPING.DONE%                       'First time only
  31. 310   WIDTH 80                                         '80 columns
  32. 320   SCREEN 0,1,0,0                                   'Select text mode
  33. 330   COLOR 10,0,0                                     'Bright green on black
  34. 340   CLS                                              'Clear the screen
  35. 350   HOUSEKEEPING.DONE% = -1                          'Set switch
  36. 360 WEND
  37. 370 WHILE INKEY.VALUE% > 0                             'After 1st time
  38. 380   PRINT
  39. 390   PRINT "Demonstration ";ANY.KEY$;" complete."     'Message
  40. 400   PRINT
  41. 410   PRINT "Press any key to continue."               'Message
  42. 420   ANY.KEY$ = ""                                    'Force 1 loop
  43. 430   WHILE ANY.KEY$ = ""                              'Wait for key press
  44. 440     ANY.KEY$ = INKEY$                              'Scan keyboard
  45. 450   WEND
  46. 460   INKEY.VALUE% = 0                                 'Reset switch
  47. 470 WEND
  48. 480 '-----  Menu routine
  49. 490 CLS                                                'Clear the screen
  50. 500 PRINT
  51. 510 PRINT "      Press a number key to select a demonstration."
  52. 520 PRINT
  53. 530 PRINT "      1 -- List some lines and return to the menu."
  54. 540 PRINT "      2 -- Stop the program and return to the menu."
  55. 550 PRINT "      3 -- End the program and return to the menu."
  56. 560 PRINT "      4 -- Renumber the program and return to the menu."
  57. 570 PRINT "      5 -- Delete some lines and return to the menu."
  58. 580 PRINT "      6 -- Exit to DOS and do a DIR *.BAS."
  59. 590 PRINT "      7 -- Exit to BASIC."
  60. 600 '
  61. 610 ANY.KEY$ = ""                                      'Force 1 loop
  62. 620 WHILE ANY.KEY$ = ""                                'Wait for key press
  63. 630   ANY.KEY$ = INKEY$                                'Scan keyboard
  64. 640   IF LEN(ANY.KEY$) > 1 THEN ANY.KEY$ = ""          '1 key only
  65. 650   IF ANY.KEY$ < "1" THEN ANY.KEY$ = ""             'Must be > 0
  66. 660   IF ANY.KEY$ > "7" THEN ANY.KEY$ = ""             'Must be < 8
  67. 670 WEND
  68. 680 '
  69. 690 BUFF.1$ = "beep:goto 1" + CHR$(13)                 'Load the string
  70. 700 GOSUB 5090                                         'Load the buffer
  71. 710 CLS                                                'Clear the screen
  72. 720 '
  73. 730 INKEY.VALUE% = VAL(ANY.KEY$)                       'Get value of inkey$
  74. 740 ON INKEY.VALUE% GOTO 810,870,930,990,1230,1500,1600 'Branch on menu option
  75. 750 BEEP
  76. 760 PRINT "Unexpected value for INKEY.VALUE%."         'Message
  77. 770 STOP
  78. 780 '
  79. 790 '-----  List some lines and return to the menu."
  80. 800 '
  81. 810 PRINT "Listing some lines."                        'Message
  82. 820 PRINT
  83. 830 LIST 1-140                                         'List some lines
  84. 840 '
  85. 850 '-----  Stop the program and return to the menu."
  86. 860 '
  87. 870 PRINT "Stoping the program."                       'Message
  88. 880 PRINT
  89. 890 STOP                                               'Exit to command level
  90. 900 '
  91. 910 '-----  End the program and return to the menu."
  92. 920 '
  93. 930 PRINT "Ending the program."                        'Message
  94. 940 PRINT
  95. 950 END                                                'Exit to command level
  96. 960 '
  97. 970 '-----  Renumber the program and return to the menu."
  98. 980 '
  99. 990 PRINT "I am going to list some of the program,"    'Message
  100. 1000 PRINT "and then renumber it and list again."       'Message
  101. 1010 PRINT
  102. 1020 FOR LOOP% = 1 TO 3000 : NEXT                       'Wait
  103. 1030 BUFF.1$ = "x=1:goto 1" + CHR$(13)                  'Continue this test
  104. 1040 GOSUB 5090                                         'Load the buffer
  105. 1050 LIST -140                                          'List the program
  106. 1060 PRINT
  107. 1070 PRINT "Renumbering program by 1's."                'Message
  108. 1080 FOR LOOP% = 1 TO 3000 : NEXT                       'Wait
  109. 1090 BUFF.1$ = "x=2:goto 1" + CHR$(13)                  'Continue this test
  110. 1100 GOSUB 5090                                         'Load the buffer
  111. 1110 RENUM 1,,1                                         'Renumber by 1's
  112. 1120 PRINT
  113. 1130 PRINT "Renumbering complete - wait for list."      'Message
  114. 1140 FOR LOOP% = 1 TO 3000 : NEXT                       'Wait
  115. 1150 BUFF.1$ = "x=3:goto 1" + CHR$(13)                  'Continue this test
  116. 1160 GOSUB 5090                                         'Load the buffer
  117. 1170 LIST -140                                          'List some lines
  118. 1180 X = 0                                              'Reset switch
  119. 1190 GOTO 1
  120. 1200 '
  121. 1210 '-----  Delete some lines and return to the menu
  122. 1220 '
  123. 1230 PRINT "I am going to list some of the program,"    'Message
  124. 1240 PRINT "and then delete some lines and list again." 'Message
  125. 1250 PRINT
  126. 1260 FOR LOOP% = 1 TO 3000 : NEXT                       'Wait
  127. 1270 BUFF.1$ = "y=1:goto 1" + CHR$(13)                  'Continue this test
  128. 1280 GOSUB 5090                                         'Load the buffer
  129. 1290 LIST -140                                          'List the program
  130. 1300 PRINT
  131. 1310 PRINT "Deleting some lines."                       'Message
  132. 1320 FOR LOOP% = 1 TO 3000 : NEXT                       'Wait
  133. 1330 BUFF.1$ = "y=2:goto 1" + CHR$(13)                  'Continue this test
  134. 1340 GOSUB 5090                                         'Load the buffer
  135. 1350 DELETE 20-80                                       'Delete some lines
  136. 1360 PRINT
  137. 1370 PRINT "Delete complete - wait for list."           'Message
  138. 1380 FOR LOOP% = 1 TO 3000 : NEXT                       'Wait
  139. 1390 BUFF.1$ = "y=3:goto 1" + CHR$(13)                  'Continue this test
  140. 1400 GOSUB 5090                                         'Load the buffer
  141. 1410 LIST -140                                          'List some lines
  142. 1420 Y = 0                                              'Reset switch
  143. 1430 INKEY.VALUE% = 5                                   'Lost during delete
  144. 1440 ANY.KEY$ = "5"                                     'Lost during delete
  145. 1450 HOUSEKEEPING.DONE% = -1                            'Lost during delete
  146. 1460 GOTO 1
  147. 1470 '
  148. 1480 '-----  Exit to DOS
  149. 1490 '
  150. 1500 CLS                                                'Clear the screen
  151. 1510 PRINT
  152. 1520 PRINT "You are in DOS"                             'Display a message
  153. 1530 PRINT
  154. 1540 BUFF.1$ = "DIR *.BAS" + CHR$(13)                   'Do a directory
  155. 1550 GOSUB 5090                                         'Load the buffer
  156. 1560 SYSTEM                                             'Exit to DOS
  157. 1570 '
  158. 1580 '-----  Exit this demo
  159. 1590 '
  160. 1600 CLS                                                'Clear the screen
  161. 1610 PRINT
  162. 1620 PRINT "You are in BASIC"                           'Display a message
  163. 1630 PRINT
  164. 1640 POKE 1052, PEEK(1050)                              'Clear keyboard buffer
  165. 1650 END                                                'Exit to BASIC
  166. 5000 'LISTING 2
  167. 5010 '
  168. 5020 'BUFFLOAD.SUB clears and optionally loads the keyboard buffer
  169. 5030 '
  170. 5040 '=====>  Load Keyboard Buffer
  171. 5050 '
  172. 5060 '----  If BUFF.1$ and BUFF.